---
title: "Table 3"
author: "Yingjie Fan"
date: "2023-06-02"
---

```{r echo=FALSE, message=FALSE, warning=FALSE}
rm(list=ls())
#install.packages(c("dplyr", "tidyr", "zoo", "data.table","nlme"))
#Load Packages
library(dplyr)
library(tidyr)
library(data.table)
library(zoo)
library(nlme)
path = "" # Insert path
```

```{r Table 3:ITSA for Tweet Volume, results='asis'}
vol_d<-fread(paste0(path,'/Data/Tweets/vol_daily_summary.csv'))%>%
  mutate(timestamp=as.Date(timestamp))%>%
  mutate(month=as.yearmon(substr(timestamp,1,7)))%>%
  mutate(D=ifelse(timestamp>="2017-07-20",1,0))%>%
  mutate(T=as.numeric(timestamp)-as.numeric(as.Date("2017-07-01")))%>%
  filter(!between(timestamp, as.Date("2017-05-01"), as.Date("2017-09-01")))

volume_irts_result<-lapply(split(vol_d, factor(vol_d$username)), function(x)gls(n ~ T + D + T*D, data=x, correlation = corAR1(form = ~ 1),na.action = na.omit))

summary(volume_irts_result$CGTN)
summary(volume_irts_result$Xinhua)
summary(volume_irts_result$`People's Daily`)
summary(volume_irts_result$`China Daily`)
```